package com.ssm.service.impl;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ssm.mapper.ProfessorMapper;
import com.ssm.model.AssessPlanModel;
import com.ssm.model.ProfessorModel;
import com.ssm.model.TeacherModel;
import com.ssm.service.ProfessorService;

@Service
public class ProfessorServiceImpl implements ProfessorService {

	@Autowired
	private ProfessorMapper professorMapper;

	@Override
	public Page<ProfessorModel> selectProfessor(Integer pageNum, String professorName) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageNum, 5);
		HashMap<String, Object> map = new HashMap<>();
		map.put("pName", professorName);
		Page<ProfessorModel> professorModels = (Page<ProfessorModel>)professorMapper.selectProfessor(map);
		return professorModels;
	}

	@Override
	public List<ProfessorModel> selectAll() {
		// TODO Auto-generated method stub
		return professorMapper.selectAll();
	}

	@Override
	public ProfessorModel selectById(Integer pId) {
		// TODO Auto-generated method stub
		return professorMapper.selectById(pId);
	}
	/*front*/
	@Override
	public Integer updateInfo(ProfessorModel professorModel) {
		// TODO Auto-generated method stub
		return professorMapper.updateInfo(professorModel);
	}
	
	@Override
	public Integer updateVerifyByEmail(Integer pId, String email, String verify) {
		// TODO Auto-generated method stub
		HashMap map = new HashMap<>();
		map.put("pId", pId);
		map.put("email", email);
		map.put("verify", verify);
		return professorMapper.updateVerifyByEmail(map);
	}

	@Override
	public Integer checkVerify(Integer pId, String email, String verify) {
		// TODO Auto-generated method stub
		HashMap map = new HashMap<>();
		map.put("pId", pId);
		map.put("email", email);
		map.put("verify", verify);
		return professorMapper.checkVerify(map);
	}

	@Override
	public Page<TeacherModel> selectTeacherByPid(Integer pId,Integer pageNum) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageNum, 5);
		List<TeacherModel> teacherModels = professorMapper.selectTeacherByPid(pId);
		return (Page<TeacherModel>) teacherModels;
	}

	@Override
	public AssessPlanModel selectAssessPlanByTid(Integer tId) {
		// TODO Auto-generated method stub
		return professorMapper.selectAssessPlanByTid(tId);
	}

	
	
	
}
